package us.impl;

import us.IClientUS;
import dao.IUserDao;
import entities.User;

public class ClientUS implements IClientUS {

	private IUserDao userDao;

	public void createUser(User user) {
		userDao.persist(user);
	}

	public boolean isAvailable(String pseudo) {
		return userDao.find(pseudo) == null;
	}

	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public boolean checkLoginPass(String login, String pass) {
		User user = userDao.find(login);
		if (user != null) {
			return pass.equals(user.getPassword());
		}
		return false;
	}

	@Override
	public User find(String login) {
		return userDao.find(login);
	}

}